 package server.commands;

 import client.MapleCharacter;
 import client.MapleClient;
 import client.inventory.Item;
 import client.inventory.MapleInventoryType;
 import constants.BattleConstants;
 import constants.ItemConstants;
 import scripting.npc.NPCScriptManager;
 import server.MapleInventoryManipulator;
 import server.MapleItemInformationProvider;
 import server.PokemonBattle;
 import tools.DateUtil;
 import tools.StringUtil;





 public class SuperDonatorCommand
 {
   public static PlayerGMRank getPlayerLevelRequired() {
/*  23 */     return PlayerGMRank.SUPERDONATOR;
   }

   public static class Challenge
     extends CommandExecute
   {
     public int execute(MapleClient c, String[] splitted) {
/*  30 */       if (splitted.length <= 1) {
/*  31 */         c.getPlayer().dropMessage(6, "@challenge [playername OR accept/decline OR block/unblock]");
/*  32 */         return 0;
       }
/*  34 */       if (c.getPlayer().getBattler(0) == null) {
/*  35 */         c.getPlayer().dropMessage(6, "You have no monsters!");
/*  36 */         return 0;
       }
/*  38 */       if (splitted[1].equalsIgnoreCase("accept")) {
/*  39 */         if (c.getPlayer().getChallenge() > 0) {
/*  40 */           MapleCharacter chr = c.getPlayer().getMap().getCharacterById(c.getPlayer().getChallenge());
/*  41 */           if (chr != null) {
/*  42 */             if ((c.getPlayer().isInTownMap() || c.getPlayer().isGM() || chr.isInTownMap() || chr.isGM()) && chr.getBattler(0) != null && chr.getChallenge() == c.getPlayer().getId() && chr.getBattle() == null && c.getPlayer().getBattle() == null) {
/*  43 */               if ((c.getPlayer().getPosition()).y != (chr.getPosition()).y) {
/*  44 */                 c.getPlayer().dropMessage(6, "Please be near them.");
/*  45 */                 return 0;
/*  46 */               }  if (c.getPlayer().getPosition().distance(chr.getPosition()) > 600.0D || c.getPlayer().getPosition().distance(chr.getPosition()) < 400.0D) {
/*  47 */                 c.getPlayer().dropMessage(6, "Please be at a moderate distance from them.");
/*  48 */                 return 0;
               }
/*  50 */               chr.setChallenge(0);
/*  51 */               chr.dropMessage(6, c.getPlayer().getName() + " has accepted!");
/*  52 */               c.getPlayer().setChallenge(0);
/*  53 */               PokemonBattle battle = new PokemonBattle(chr, c.getPlayer());
/*  54 */               chr.setBattle(battle);
/*  55 */               c.getPlayer().setBattle(battle);
/*  56 */               battle.initiate();
             } else {
/*  58 */               c.getPlayer().dropMessage(6, "You may only use it in towns, or the other character has no monsters, or something failed.");
             }
           } else {
/*  61 */             c.getPlayer().dropMessage(6, "They do not exist in the map.");
           }
         } else {
/*  64 */           c.getPlayer().dropMessage(6, "You don't have a challenge.");
         }
/*  66 */       } else if (splitted[1].equalsIgnoreCase("decline")) {
/*  67 */         if (c.getPlayer().getChallenge() > 0) {
/*  68 */           c.getPlayer().cancelChallenge();
         } else {
/*  70 */           c.getPlayer().dropMessage(6, "You don't have a challenge.");
         }
/*  72 */       } else if (splitted[1].equalsIgnoreCase("block")) {
/*  73 */         if (c.getPlayer().getChallenge() == 0) {
/*  74 */           c.getPlayer().setChallenge(-1);
/*  75 */           c.getPlayer().dropMessage(6, "You have blocked challenges.");
         } else {
/*  77 */           c.getPlayer().dropMessage(6, "You have a challenge or they are already blocked.");
         }
/*  79 */       } else if (splitted[1].equalsIgnoreCase("unblock")) {
/*  80 */         if (c.getPlayer().getChallenge() < 0) {
/*  81 */           c.getPlayer().setChallenge(0);
/*  82 */           c.getPlayer().dropMessage(6, "You have unblocked challenges.");
         } else {
/*  84 */           c.getPlayer().dropMessage(6, "You didn't block challenges.");
         }

/*  87 */       } else if (c.getPlayer().getChallenge() == 0) {
/*  88 */         MapleCharacter chr = c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
/*  89 */         if (chr != null && chr.getMap() == c.getPlayer().getMap() && chr.getId() != c.getPlayer().getId()) {
/*  90 */           if ((c.getPlayer().isInTownMap() || c.getPlayer().isGM() || chr.isInTownMap() || chr.isGM()) && chr.getBattler(0) != null && chr.getChallenge() == 0 && chr.getBattle() == null && c.getPlayer().getBattle() == null) {
/*  91 */             chr.setChallenge(c.getPlayer().getId());
/*  92 */             chr.dropMessage(6, c.getPlayer().getName() + " has challenged you! Type @challenge [accept/decline] to answer!");
/*  93 */             c.getPlayer().setChallenge(chr.getId());
/*  94 */             c.getPlayer().dropMessage(6, "Successfully sent the request.");
           } else {
/*  96 */             c.getPlayer().dropMessage(6, "You may only use it in towns, or the other character has no monsters, or they have a challenge.");
           }
         } else {
/*  99 */           c.getPlayer().dropMessage(6, splitted[1] + " does not exist in the map.");
         }
       } else {
/* 102 */         c.getPlayer().dropMessage(6, "You have a challenge or you have blocked them.");
       }

/* 105 */       return 1;
     }
   }

   public static abstract class OpenNPCCommand
     extends CommandExecute {
/* 111 */     private static final int[] npcs = new int[] { 9270035, 9270035, 9270035, 9270035, 9270035, 9270035, 9270035 };







/* 119 */     protected int npc = -1;



     public int execute(MapleClient c, String[] splitted) {
/* 124 */       if (this.npc != 6 && this.npc != 5 && this.npc != 4 && this.npc != 3 && this.npc != 1 && c.getPlayer().getMapId() != 910000000) {
/* 125 */         if (c.getPlayer().getLevel() < 10 && c.getPlayer().getJob() != 200) {
/* 126 */           c.getPlayer().dropMessage(5, "等级达到10级才可以使用这个命令.");
/* 127 */           return 0;
         }
/* 129 */         if (c.getPlayer().isInBlockedMap()) {
/* 130 */           c.getPlayer().dropMessage(5, "无法在这里使用这个命令.");
/* 131 */           return 0;
         }
/* 133 */       } else if (this.npc == 1 && 
/* 134 */         c.getPlayer().getLevel() < 70) {
/* 135 */         c.getPlayer().dropMessage(5, "等级达到70级才可以使用这个命令.");
/* 136 */         return 0;
       }

/* 139 */       if (c.getPlayer().hasBlockedInventory()) {
/* 140 */         c.getPlayer().dropMessage(5, "无法在这里使用这个命令.");
/* 141 */         return 0;
       }
/* 143 */       NPCScriptManager.getInstance().start(c, npcs[this.npc]);
/* 144 */       return 1;
     }
   }











   public static class openNpc
     extends OpenNPCCommand {}











   public static class DCash
     extends OpenNPCCommand {}











   public static class Event
     extends OpenNPCCommand {}











   public static class CheckDrop
     extends OpenNPCCommand {}










   public static class Pokedex
     extends OpenNPCCommand {}










   public static class Pokemon
     extends OpenNPCCommand {}










   public static class TSmega
     extends CommandExecute
   {
     public int execute(MapleClient c, String[] splitted) {
/* 237 */       c.getPlayer().setSmega();
/* 238 */       return 1;
     }
   }

   public static class Check
     extends CommandExecute
   {
     public int execute(MapleClient c, String[] splitted) {
/* 246 */       c.getPlayer().dropMessage(6, "你当前有 " + c.getPlayer().getCSPoints(1) + " 点券.");
/* 247 */       c.getPlayer().dropMessage(6, "你当前有 " + c.getPlayer().getMaplePoints() + " 抵用券.");
/* 248 */       c.getPlayer().dropMessage(6, "你当前有 " + c.getPlayer().getVPoints() + " voting points.");
/* 249 */       c.getPlayer().dropMessage(6, "你当前有 " + c.getPlayer().getIntNoRecord(150001) + " BOSS、组队点数.");
/* 250 */       c.getPlayer().dropMessage(6, "当前时间: " + DateUtil.getNowTime());
/* 251 */       return 1;
     }
   }

   public static class TradeHelp
     extends CommandExecute.TradeExecute
   {
     public int execute(MapleClient c, String[] splitted) {
/* 259 */       c.getPlayer().dropMessage(-2, "[系统提示] : <@offerequip, @offeruse, @offersetup, @offeretc, @offercash> <数量> <道具名称>");
/* 260 */       return 1;
     }
   }

   public static abstract class OfferCommand
     extends CommandExecute.TradeExecute {
/* 266 */     protected int invType = -1;


     public int execute(MapleClient c, String[] splitted) {
/* 270 */       if (splitted.length < 3) {
/* 271 */         c.getPlayer().dropMessage(-2, "[错误] : <数量> <道具名称>");
/* 272 */       } else if (c.getPlayer().getLevel() < 70) {
/* 273 */         c.getPlayer().dropMessage(-2, "[错误] : 只有等级达到70级以上的玩家才能使用这个命令");
       } else {
/* 275 */         int quantity = 1;
         try {
/* 277 */           quantity = Integer.parseInt(splitted[1]);
/* 278 */         } catch (Exception exception) {}

/* 280 */         String search = StringUtil.joinStringFrom(splitted, 2).toLowerCase();
/* 281 */         Item found = null;
/* 282 */         MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
/* 283 */         for (Item inv : c.getPlayer().getInventory(MapleInventoryType.getByType((byte)this.invType))) {
/* 284 */           if (ii.getName(inv.getItemId()) != null && ii.getName(inv.getItemId()).toLowerCase().contains(search)) {
/* 285 */             found = inv;
             break;
           }
         }
/* 289 */         if (found == null) {
/* 290 */           c.getPlayer().dropMessage(-2, "[错误] : 没有找到该道具 (" + search + ")");
/* 291 */           return 0;
         }
/* 293 */         if (ItemConstants.isPet(found.getItemId()) || ItemConstants.isRechargable(found.getItemId())) {
/* 294 */           c.getPlayer().dropMessage(-2, "[错误] : 这个道具无法使用这个命令来进行交易");
/* 295 */           return 0;
         }
/* 297 */         if (quantity > found.getQuantity() || quantity <= 0 || quantity > ii.getSlotMax(found.getItemId())) {
/* 298 */           c.getPlayer().dropMessage(-2, "[错误] : 输入的数量无效");
/* 299 */           return 0;
         }
/* 301 */         if (!c.getPlayer().getTrade().setItems(c, found, (byte)-1, quantity)) {
/* 302 */           c.getPlayer().dropMessage(-2, "[错误] : 放入道具失败");
/* 303 */           return 0;
         }
/* 305 */         c.getPlayer().getTrade().chatAuto("[系统提示] : " + c.getPlayer().getName() + " offered " + ii.getName(found.getItemId()) + " x " + quantity);
       }

/* 308 */       return 1;
     }
   }





   public static class OfferEquip
     extends OfferCommand {}





   public static class OfferUse
     extends OfferCommand {}




   public static class OfferSetup
     extends OfferCommand {}




   public static class OfferEtc
     extends OfferCommand {}




   public static class OfferCash
     extends OfferCommand {}




   public static class BattleHelp
     extends CommandExecute.PokemonExecute
   {
     public int execute(MapleClient c, String[] splitted) {
/* 351 */       c.getPlayer().dropMessage(-3, "(...I can use @use <attack name> to take down the enemy...)");
/* 352 */       c.getPlayer().dropMessage(-3, "(...I can use @info to check out the stats of my battle...)");
/* 353 */       c.getPlayer().dropMessage(-3, "(...I can use @ball <basic, great, ultra> to use an ball, but only if I have it...)");
/* 354 */       c.getPlayer().dropMessage(-3, "(...I can use @run if I don't want to fight anymore...)");
/* 355 */       c.getPlayer().dropMessage(-4, "(...This is a tough choice! What do I do?...)");
/* 356 */       return 1;
     }
   }

   public static class Ball
     extends CommandExecute.PokemonExecute
   {
     public int execute(MapleClient c, String[] splitted) {
/* 364 */       if (c.getPlayer().getBattle().getInstanceId() < 0 || c.getPlayer().getBattle().isTrainerBattle()) {
/* 365 */         c.getPlayer().dropMessage(-3, "(...I can't use it in a trainer battle...)");
/* 366 */         return 0;
       }
/* 368 */       if (splitted.length <= 1) {
/* 369 */         c.getPlayer().dropMessage(-3, "(...I can use @ball <basic, great, or ultra> if I have the ball...)");
/* 370 */         return 0;
       }
/* 372 */       BattleConstants.PokemonItem item = null;
/* 373 */       if (splitted[1].equalsIgnoreCase("basic")) {
/* 374 */         item = BattleConstants.PokemonItem.Basic_Ball;
/* 375 */       } else if (splitted[1].equalsIgnoreCase("great")) {
/* 376 */         item = BattleConstants.PokemonItem.Great_Ball;
/* 377 */       } else if (splitted[1].equalsIgnoreCase("ultra")) {
/* 378 */         item = BattleConstants.PokemonItem.Ultra_Ball;
       }
/* 380 */       if (item != null) {
/* 381 */         if (c.getPlayer().haveItem(item.id, 1)) {
/* 382 */           if (c.getPlayer().getBattle().useBall(c.getPlayer(), item)) {
/* 383 */             MapleInventoryManipulator.removeById(c, ItemConstants.getInventoryType(item.id), item.id, 1, false, false);
           } else {
/* 385 */             c.getPlayer().dropMessage(-3, "(...The monster is too strong, maybe I don't need it...)");
/* 386 */             return 0;
           }
         } else {
/* 389 */           c.getPlayer().dropMessage(-3, "(...I don't have a " + splitted[1] + " ball...)");
/* 390 */           return 0;
         }
       } else {
/* 393 */         c.getPlayer().dropMessage(-3, "(...I can use @ball <basic, great, or ultra> if I have the ball...)");
/* 394 */         return 0;
       }
/* 396 */       return 1;
     }
   }

   public static class Info
     extends CommandExecute.PokemonExecute
   {
     public int execute(MapleClient c, String[] splitted) {
/* 404 */       NPCScriptManager.getInstance().start(c, 9000021);
/* 405 */       return 1;
     }
   }

   public static class Run
     extends CommandExecute.PokemonExecute
   {
     public int execute(MapleClient c, String[] splitted) {
/* 413 */       c.getPlayer().getBattle().forfeit(c.getPlayer(), false);
/* 414 */       return 1;
     }
   }

   public static class Use
     extends CommandExecute.PokemonExecute
   {
     public int execute(MapleClient c, String[] splitted) {
/* 422 */       if (splitted.length <= 1) {
/* 423 */         c.getPlayer().dropMessage(-3, "(...I need an attack name...)");
/* 424 */         return 0;
       }
/* 426 */       if (!c.getPlayer().getBattle().attack(c.getPlayer(), StringUtil.joinStringFrom(splitted, 1))) {
/* 427 */         c.getPlayer().dropMessage(-3, "(...I've already selected an action...)");
       }
/* 429 */       return 1;
     }
   }
 }


/* Location:              C:\PGX\Server.jar!\server\commands\SuperDonatorCommand.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */